package com.cip.master.dao.impl;

import java.util.List;

import com.cip.admin.dao.impl.CipHibernateDAOSupport;
import com.cip.master.dao.ClassYearDAO;
import com.cip.master.model.ClassYear;

public class ClassYearDAOImpl extends CipHibernateDAOSupport implements
		ClassYearDAO {

	public ClassYear saveOrUpdate(ClassYear classYear) {
		getHibernateTemplate().saveOrUpdate(classYear);
		return classYear;
	}

	public List<ClassYear> getAllClassYear() throws Exception {
		return getCipHibernateTemplate().loadAll(ClassYear.class);	
	}

	public ClassYear getClassYear(int id) {
		return getHibernateTemplate().get(ClassYear.class, id);
	}
	
	public ClassYear getClassYearByName(String name) throws Exception{
		String query="select classYear from ClassYear as classYear where classYear.name='"+name+"'";
		return (ClassYear)getCipHibernateTemplate().find(query).get(0);
	}

}
